//BusClearingCcbpayBatchModel
//2020-08-11 18:51:22

package models

import (
	"git.900sui.cn/kc/base/common/functions"
	"git.900sui.cn/kc/base/common/models/base"
	"git.900sui.cn/kc/kcgin/orm"
)

const (
	STATUS_none = 0
	STATUS_SUC  = 1
)

//表结构体
type BusClearingCcbpayBatchModel struct {
	Model *base.Model
	Field BusClearingCcbpayBatchModelField
}

//表字段
type BusClearingCcbpayBatchModelField struct {
	T_table     string `default:"bus_clearing_ccbpay_batch"`
	F_id        string `default:"id"`
	F_batch_no  string `default:"batch_no"`
	F_file_name string `default:"file_name"`
	F_file_path string `default:"file_path"`
	F_status    string `default:"status"`
	F_date_ymd  string `default:"date_ymd"`
	F_date_time string `default:"date_time"`
}

//初始化
func (b *BusClearingCcbpayBatchModel) Init(ormer ...orm.Ormer) *BusClearingCcbpayBatchModel {
	functions.ReflectModel(&b.Field)
	b.Model = base.NewModel(b.Field.T_table, ormer...)
	return b
}

//新增数据
func (b *BusClearingCcbpayBatchModel) Insert(data map[string]interface{}) int {
	result, _ := b.Model.Data(data).Insert()
	return result
}

// 修改数据
func (b *BusClearingCcbpayBatchModel) UpdateById(id int, data map[string]interface{}) (int, error) {
	return b.Model.Where(map[string]interface{}{
		b.Field.F_id: id,
	}).Data(data).Update()
}

// 修改数据
func (b *BusClearingCcbpayBatchModel) UpdateByBatchNo(batchNo string, data map[string]interface{}) (int, error) {
	return b.Model.Where(map[string]interface{}{
		b.Field.F_batch_no: batchNo,
	}).Data(data).Update()
}

// 根据状态查询记录
func (b *BusClearingCcbpayBatchModel) GetListsByStatus(status, count int) []map[string]interface{} {
	return b.Model.Where(map[string]interface{}{
		b.Field.F_status: status,
	}).Limit(0, count).Select()
}
